<template>
	<view class="main">
		<view class="content" style="padding: 16px 16px;">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="top" style="margin-bottom: 10px;display: flex;justify-content: space-between;" v-show="index!=0">
					{{item.name}}
          
          <view style="display: flex;align-items: baseline;" v-if="item.code =='czwt'" @click="Qshow = true">请选择 <u-icon name="arrow-down"></u-icon></view>
				</view>
				<!-- 输入框组 -->
				<view class="a" v-if="item.type==1">
					<view class="a1" v-if="item.code!='zdry'">
						<u--textarea v-model="item.value" placeholder="请输入" style="background-color: #FFF;"
							autoHeight></u--textarea>
					</view>
					<view class="a2" v-if="item.code=='zdry'">
						<u--textarea v-model="item.value" placeholder="请输入(多个输入以、隔开名字)" style="background-color: #FFF;"
							autoHeight></u--textarea>
					</view>
				</view>
				<!-- 选择框组 -->
				<view class="b" v-if="item.type==2">
					<view class="opt"
						style="width: 100%;background-color: #FFF;border: #e7e6e4 0.5px solid;border-radius: 5px;">
						<!-- 项目名称 -->
						<view v-if="item.code=='xmmc'" class="xmmc" @click="getProject()"
							style="padding: 9px 9px;display: flex;justify-content: space-between;align-items: center;">
							<view class="opt1" v-show="item.value==''" style="color: #c0c4cc;font-size: 15px;">
								{{'请选择'}}
							</view>
							<view class="opt2" v-show="item.value!=''">
								{{item.value}}
							</view>
							<view class="opt3">
								<u-icon name="arrow-down" style="margin-top: 3px;"></u-icon>
							</view>
						</view>
						<!-- 建设单位 -->
						<view v-if="item.code=='jsdw'" class="jsdw" @click="getJSDW()"
							style="padding: 9px 9px;display: flex;justify-content: space-between;align-items: center;">
							<view class="opt1" v-show="item.value==''" style="color: #c0c4cc;font-size: 15px;">
								{{'请选择'}}
							</view>
							<view class="opt2" v-show="item.value!=''">
								{{item.value}}
							</view>
							<view class="opt3">
								<u-icon name="arrow-down" style="margin-top: 3px;"></u-icon>
							</view>
						</view>
						<!-- 责任部门 -->
						<view v-if="item.code=='trbm'" class="trbm" @click="getTRDM()"
							style="padding: 9px 9px;display: flex;justify-content: space-between;align-items: center;">
							<view class="opt1" v-show="item.value==''" style="color: #c0c4cc;font-size: 15px;">
								{{'请选择'}}
							</view>
							<view class="opt2" v-show="item.value!=''">
								{{item.value}}
							</view>
							<view class="opt3">
								<u-icon name="arrow-down" style="margin-top: 3px;"></u-icon>
							</view>
						</view>
					</view>
				</view>
				<!-- 日期时间选择器 -->
				<view class="c" v-if="item.type==3">
					<view class="opt"
						style="width: 100%;background-color: #FFF;border: #e7e6e4 0.5px solid;border-radius: 5px;">
						<view class="trbm" @click="getTime()"
							style="padding: 9px 9px;display: flex;justify-content: left;align-items: center;">
							<view class="opt3">
								<u-icon name="clock" style="margin-top: 2px;margin-right: 5px;"></u-icon>
							</view>
							<view class="opt1" v-show="item.value==''" style="color: #c0c4cc;font-size: 15px;">
								{{'请选择时间'}}
							</view>
							<view class="opt2" v-show="item.value!=''">
								{{item.value}}
							</view>
						</view>
					</view>
				</view>
				<!-- 文本域框组 -->
				<view class="d" v-if="item.type==4">
					<view class="d1" v-show="item.code=='czwt'">
						<u--textarea v-model="item.value" placeholder="请输入存在问题" count autoHeight
							maxlength="1000"></u--textarea>
					</view>
					<view class="d2" v-show="item.code!=='czwt'">
						<u--textarea v-model="item.value" placeholder="请输入" count autoHeight
							maxlength="1000"></u--textarea>
					</view>
				</view>
				<!-- 日期选择器 -->
				<view class="e" v-if="item.type==7">
					<view class="opt"
						style="width: 100%;background-color: #FFF;border: #e7e6e4 0.5px solid;border-radius: 5px;">
						<view class="trbm" @click="getTimeDate()"
							style="padding: 9px 9px;display: flex;justify-content: left;align-items: center;">
							<view class="opt3">
								<u-icon name="clock" style="margin-top: 2px;margin-right: 5px;"></u-icon>
							</view>
							<view class="opt1" v-show="item.value==''" style="color: #c0c4cc;font-size: 15px;">
								{{'请选择日期'}}
							</view>
							<view class="opt2" v-show="item.value!=''">
								{{item.value}}
							</view>
						</view>
					</view>
				</view>
				<div style="margin: 10px 0px;" v-show="index!=0"><u-line></u-line></div>
			</view>
			<!-- 图片框组 -->
			<view class="photo">
				<view class="top" style="margin-bottom: 10px;">现场照片</view>
				<view
					style="border: 0.5px solid #e7e6e4;width: 100%;height: 72px;margin-top: 8px;display: flex;border-radius: 5px;background-color: #FFF;">
					<view class="aaa" style="display: flex;" v-for="(item,index) in fileTempList" :key="index">
						<view style="position: relative; margin-top: 8px; margin-left: 8px;">
							<u--image :src="item.url" width="55px" height="55px"></u--image>
							<u-icon name="close" style="position: absolute; top: 2px; right: 2px;"
								@click="removeItem(index)"></u-icon>
						</view>
					</view>
					<u--image :src="upLoadUrl" v-show="fileTempList.length<5" width="55px" height="55px"
						style="margin-top: 8px;margin-left: 8px;" @click="getFile"></u--image>
				</view>
			</view>
			<!-- 按钮框组 -->
			<view class="btn" style="margin: 10px 0px;">
				<u-button @click="submit" color="#FF5500" :loading="loading" text="提 交"></u-button>
				<u-button @click="reset" plain text="重 置" style="margin-top: 10px;"></u-button>
			</view>
		</view>

		<!-- 项目名称pop -->
		<u-popup :show="pshow" :round="10" mode="bottom" @close="pshow=false">
			<view style="height: 60vh;">
				<view class="ptop" style="margin: 10px;">
					<u-search v-model="keyword" @search="getprojectList()" @custom="getprojectList()"
						:clearabled="false"></u-search>
				</view>
				<u-list height="52vh">
					<u-list-item v-for="(item, index) in projectList" :key="index">
						<u-cell @click="chooseproject(item)">
							<view slot="title" class="cleft" style="width: 80vw;">
								{{ item.xmmc }}
							</view>
							<view slot="right-icon" class="aright" v-show="project.xmmc==item.xmmc">
								<u-icon name="checkmark" color="#FF5500"></u-icon>
							</view>
						</u-cell>
					</u-list-item>
				</u-list>
			</view>
		</u-popup>

		<!-- 建设单位pop -->
		<u-popup :show="ashow" :round="10" mode="bottom" @close="ashow=false">
			<view class="amain" style="height: 60vh;">
				<view class="atop" style="padding: 20px 10px;display: flex;align-items: center;">
					<u-icon name="arrow-left" size="18" @click="getOld()" style="margin-top: 2px;"></u-icon>
					<view class="titlea" style="margin-left: 5px;color: #FF5500;display: flex;flex-wrap: nowrap;">
						<view class="ta" v-for="(zoo,index) in recordDepAMap" :key="index">
							<view class="text" v-show="index!=recordDepAMap.length-1">
								{{ zoo.data.deptName + '/' }}
							</view>
							<view class="text" v-show="index==recordDepAMap.length-1">
								{{ zoo.data.deptName }}
							</view>
						</view>
					</view>
				</view>
				<u-list height="52vh">
					<u-list-item v-for="(item, index) in depListA" :key="index">
						<u-cell @click="getNext(item)">
							<view slot="title" class="aleft">
								{{ item.deptName }}
							</view>
							<view slot="right-icon" class="aright" v-show="item.children.length!=0">
								<u-icon name="arrow-right"></u-icon>
							</view>
						</u-cell>
					</u-list-item>
				</u-list>
			</view>
		</u-popup>

		<!-- 责任单位pop -->
		<u-popup :show="bshow" :round="10" mode="bottom" @close="bshow=false">
			<view class="bmain" style="height: 60vh;">
				<view class="btop" style="padding: 20px 10px;display: flex;align-items: center;">
					<u-icon name="arrow-left" size="18" @click="getOldB()" style="margin-top: 2px;"></u-icon>
					<view class="titleb" style="margin-left: 5px;color: #FF5500;display: flex;flex-wrap: nowrap;">
						<view class="tb" v-for="(zoo,index) in recordDepBMap" :key="index">
							<view class="text" v-show="index!=recordDepBMap.length-1">
								{{ zoo.data.deptName + '/' }}
							</view>
							<view class="text" v-show="index==recordDepBMap.length-1">
								{{ zoo.data.deptName }}
							</view>
						</view>
					</view>
				</view>
				<u-list height="52vh">
					<u-list-item v-for="(item, index) in depListB" :key="index">
						<u-cell @click="getNextB(item)">
							<view slot="title" class="bleft">
								{{ item.deptName }}
							</view>
							<view slot="right-icon" class="bright" v-show="item.children.length!=0">
								<u-icon name="arrow-right"></u-icon>
							</view>
						</u-cell>
					</u-list-item>
				</u-list>
			</view>
		</u-popup>

		<!-- 指导时间date -->
		<u-datetime-picker v-model="time" ref="picker" @close="timeshow=false" @cancel="timeshow=false" @confirm="setTime()"
			:show="timeshow" mode="datetime"></u-datetime-picker>
		
		<!-- 整改期限date -->
		<u-datetime-picker v-model="dateT" ref="datepicker" @close="dateshow=false" @cancel="dateshow=false" @confirm="setTimeDate()"
			:show="dateshow" mode="date"></u-datetime-picker>


    <!-- 问题 -->
    <u-popup :show="Qshow" :round="10" mode="bottom" @close="Qshow=false" closeable>
      <view style="height: 40px;"></view>
    		<u-list height="52vh">
    			<u-list-item v-for="(item, index) in questionList" :key="index">
    				<u-cell @click="chooseQ(item)">
    					<view slot="title" class="cleft" style="width: 80vw;">
    						{{ item.content }}
    					</view>
    					<view slot="right-icon" class="aright" v-show="selectedQ.includes(item.orderNumber)">
    						<u-icon name="checkmark" color="#FF5500"></u-icon>
    					</view>
    				</u-cell>
    			</u-list-item>
    		</u-list>
    </u-popup>
	</view>
</template>

<script>
	import croods from '@/common/croods-1.3.3.js';
	window.croods = croods;
	window.hydra = require('../../../../common/wst_hydra-1.0.0.js');


	import coordtransform from 'coordtransform';
	import {
		getAllProject,
    getAllProjectNew,
		getAllDepartment,
		getCurrentUser,
		getDDIC,
		getProjectDetail,
		uploadFileOfQuestion,
		addPro,
    getListIssues,
    getListGuidance
	} from '@/common/api.js'
	export default {
		onShow() {
			document.body.style.overflow = 'auto'
			this.getWsToken()
      this.getQA()
      // this.getAllProjects()
      // this.getAllDep()
		},
		data() {
			return {
				/* 请求参数 */
				query: {
					czwt: '',
					jldw: '',
					jsdw: '',
					jsdwid: 0,
					sgdw: '',
					sjdw: '',
					trbm: '',
					trbmId: 0,
					xcfj: '',
					xmid: 0,
					xmjdms: '',
					xmmc: '',
					zddw: '',
					zdry: '',
					zdsj: '',
					zdyj: '',
					zgyq: '',
					zgqx: ''
				},
				/* 表单 */
				list: [{
						name: '意见单编号',
						type: 10000,
						code: 'yjbh',
						value: ''
					},
					{
						name: '项目名称',
						type: 2,
						code: 'xmmc',
						value: '',
						id: 0
					},
					{
						name: '建设单位',
						type: 2,
						code: 'jsdw',
						value: '',
						id: 0
					},
					{
						name: '监理单位',
						type: 1,
						code: 'jldw',
						value: ''
					},
					{
						name: '施工单位',
						type: 1,
						code: 'sgdw',
						value: ''
					},
					{
						name: '设计单位',
						type: 1,
						code: 'sjdw',
						value: ''
					},
					{
						name: '责任部门',
						type: 2,
						code: 'trbm',
						value: '',
						id: 0
					},
					{
						name: '项目进度情况',
						type: 4,
						code: 'xmjdms',
						value: `项目于    开工，计划于   完工，海绵城市建设方案设计专篇于                       通过指导。海绵城市建设施工图设计专篇                                     通过图审。项目正在进行        施工；现场已基本完工。`
					},
					{
						name: '指导单位',
						type: 1,
						code: 'zddw',
						value: '芜湖市排水管理服务中心'
					},
					{
						name: '指导人员',
						type: 1,
						code: 'zdry',
						value: ''
					},
					{
						name: '指导时间',
						type: 3,
						code: 'zdsj',
						value: ''
					},
					{
						name: '存在问题',
						type: 4,
						code: 'czwt',
						value: ''
					},
					{
						name: '指导意见',
						type: 4,
						code: 'zdyj',
						value: ''
					},
					{
						name: '整改要求',
						type: 4,
						code: 'zgyq',
						value: `请建设单位于      前将整改清单（PDF盖章版）反馈至市排水中心（电子邮箱whshmb@163.com）。`
					},
					{
						name: '整改期限',
						type: 7,
						code: 'zgqx',
						value: ''
					}
				],
				/* 项目 */
				projectList: [],
				pquery: {
					id: 0,
					ssdfq: '',
					xmlb: '',
					xmmc: ''
				},
				pshow: false,
				project: '',
				keyword: '',
				/* 时间 */
				timeshow: false,
				time: Number(new Date()),
				/* 日期 */
				dateshow: false,
				dateT: Number(new Date()),
				/* 图片 */
				upLoadUrl: require("../../../../static/icons/xjyw/add.png"),
				fileNum: null,
				fileTempList: [],
				/* 部门 a建设、b责任 */
				depAllList: [],

				currentLevelA: 1,
				depListA: [],
				ashow: false,
				recordDepAList: [],
				recordDepAMap: [],

				currentLevelB: 1,
				depListB: [],
				bshow: false,
				recordDepBList: [],
				recordDepBMap: [],
				wstoken: '',
        questionList: [],
        answerList: [],
        selectedQ: [],
        Qshow: false,
        loading: false,
			}
		},
		methods: {
      getQA() {
        getListIssues().then(res => {
          this.questionList = res
        })
        getListGuidance().then(res => {
          this.answerList = res
        })
      },
      chooseQ(item) {
        if(this.selectedQ.includes(item.orderNumber)) {
          this.selectedQ = this.selectedQ.filter(i=>i!=item.orderNumber)
        }else {
          this.selectedQ.push(item.orderNumber)
        }
        const selectedQuestion =  this.questionList.filter(q=>this.selectedQ.includes(q.orderNumber)).map(i=>i.content)
        const selectedAnswer = this.answerList.filter(a=>this.selectedQ.includes(a.orderNumber)).map(i=>i.content)
        this.list.find(item=>item.code=='czwt').value= selectedQuestion.reduce((s,r,i) => s + `（${i+1}）${r};`, '现场海绵城市设施整体情况:')
        this.list.find(item=>item.code=='zdyj').value= selectedAnswer.reduce((s,r,i) => s + `（${i+1}）${r};`, '')
      },
			/* 项目 */
			getAllProjects() {
				getAllProjectNew(this.pquery).then(res => {
					this.projectList = res
          console.log(res)
				})
			},
			getProject() {
				this.pshow = true
			},
			chooseproject(item) {
				getProjectDetail({
					id: item.id
				}).then(res => {
					this.project = res
					let temp = res
					this.list[1].value = temp.xmmc
					this.list[1].id = temp.id
					this.list.forEach((item) => {
						if (temp[item.code] != '' && temp[item.code] != undefined && temp[item.code] !=
							null) {
							item.value = temp[item.code]
						}
					})
					if (temp.jsdwId != '' && temp.jsdwId != undefined && temp.jsdwId != null) {
						this.list[2].id = temp.jsdwId
					}
					if (temp.trbmId != '' && temp.trbmId != undefined && temp.trbmId != null) {
						this.list[6].id = temp.trbmId
					}
					this.pshow = false
				})
			},
			getprojectList() {
				this.pquery.xmmc = this.keyword
				getAllProjectNew(this.pquery).then(res => {
					this.projectList = res
				})
			},
			/* 单位 */
			getAllDep() {
				getAllDepartment().then(res => {
					this.depAllList = res
				})
			},
			getJSDW() {
				this.depListA = this.depAllList
				this.recordDepAList = []
				this.recordDepAList.push({
					level: 1,
					data: this.depListA
				})
				this.currentLevelA = 1
				this.recordDepAMap = []
				this.ashow = true
			},
			getNext(item) {
				let find = false
				this.recordDepAMap = this.recordDepAMap.map(obj => {
					if (obj.level == this.currentLevelA) {
						find = true
						return {
							level: obj.level,
							data: item
						}
					} else {
						return obj
					}
				})
				if (!find) {
					this.recordDepAMap.push({
						level: this.currentLevelA,
						data: item
					})
				}

				let deps = item.children

				/* 确定最后一级选择 */
				if (deps.length == 0 && item.deptName != '暂不选择') {
					let temp = ''
					/* this.recordDepAMap.forEach(zoo => {
						temp = temp + zoo.data.deptName + '/'
					})
					this.list[2].value = temp.slice(0,-1) */
					this.list[2].value = item.deptName
					this.list[2].id = item.id
					this.ashow = false
				}

				/* 暂不选择 */
				if (deps.length == 0 && item.deptName == '暂不选择') {
					let temp = ''
					/* this.recordDepAMap.forEach(zoo => {
						temp = temp + zoo.data.deptName + '/'
					})
					this.list[2].value = temp.slice(0,-6) */
					let levels = this.currentLevelA - 1
					let temps = this.recordDepAMap.find(xx => xx.level == levels)
					this.list[2].value = temps.data.deptName
					this.list[2].id = temps.data.id
					this.ashow = false
				}

				/* 进入下一级 */
				if (deps.length != 0) {
					let temp = [{
						deptName: '暂不选择',
						children: []
					}]
					this.depListA = []
					this.depListA = this.depListA.concat(temp)
					this.depListA = this.depListA.concat(deps)
					this.currentLevelA += 1
					this.recordDepAList.push({
						level: this.currentLevelA,
						data: this.depListA
					})
				}
			},
			getOld() {
				if (this.currentLevelA == 1) {
					return
				} else {
					this.recordDepAMap = this.recordDepAMap.filter(obj => obj.level != this.currentLevelA)
					this.recordDepAList = this.recordDepAList.filter(obj => obj.level != this.currentLevelA)
					this.currentLevelA = this.currentLevelA - 1
					this.recordDepAMap = this.recordDepAMap.filter(obj => obj.level != this.currentLevelA)
					let temp = this.recordDepAList.find(obj => obj.level == this.currentLevelA)
					if (temp) {
						this.depListA = temp.data
					}
				}
			},
			getTRDM() {
				this.depListB = this.depAllList
				this.recordDepBList = []
				this.recordDepBList.push({
					level: 1,
					data: this.depListB
				})
				this.currentLevelB = 1
				this.recordDepBMap = []
				this.bshow = true
			},
			getNextB(item) {
				let find = false
				this.recordDepBMap = this.recordDepBMap.map(obj => {
					if (obj.level == this.currentLevelB) {
						find = true
						return {
							level: obj.level,
							data: item
						}
					} else {
						return obj
					}
				})
				if (!find) {
					this.recordDepBMap.push({
						level: this.currentLevelB,
						data: item
					})
				}

				let deps = item.children

				/* 确定最后一级选择 */
				if (deps.length == 0 && item.deptName != '暂不选择') {
					let temp = ''
					/* this.recordDepBMap.forEach(zoo => {
						temp = temp + zoo.data.deptName + '/'
					})
					this.list[6].value = temp.slice(0,-1) */
					this.list[6].value = item.deptName
					this.list[6].id = item.id
					this.bshow = false
				}

				/* 暂不选择 */
				if (deps.length == 0 && item.deptName == '暂不选择') {
					let temp = ''
					/* this.recordDepBMap.forEach(zoo => {
						temp = temp + zoo.data.deptName + '/'
					})
					this.list[6].value = temp.slice(0,-6) */
					let levels = this.currentLevelB - 1
					let temps = this.recordDepBMap.find(xx => xx.level == levels)
					this.list[6].value = temps.data.deptName
					this.list[6].id = temps.data.id
					this.bshow = false
				}

				/* 进入下一级 */
				if (deps.length != 0) {
					let temp = [{
						deptName: '暂不选择',
						children: []
					}]
					this.depListB = []
					this.depListB = this.depListB.concat(temp)
					this.depListB = this.depListB.concat(deps)
					this.currentLevelB += 1
					this.recordDepBList.push({
						level: this.currentLevelB,
						data: this.depListB
					})
				}
			},
			getOldB() {
				if (this.currentLevelB == 1) {
					return
				} else {
					this.recordDepBMap = this.recordDepBMap.filter(obj => obj.level != this.currentLevelB)
					this.recordDepBList = this.recordDepBList.filter(obj => obj.level != this.currentLevelB)
					this.currentLevelB = this.currentLevelB - 1
					this.recordDepBMap = this.recordDepBMap.filter(obj => obj.level != this.currentLevelB)
					let temp = this.recordDepBList.find(obj => obj.level == this.currentLevelB)
					if (temp) {
						this.depListB = temp.data
					}
				}
			},
			/* 时间 */
			getTime() {
				if(this.list[10].value == ''){
					this.$refs.picker.innerValue = Number(new Date())
				}else{
					this.$refs.picker.innerValue = Number(new Date(this.list[10].value))
				}
				this.timeshow = true
			},
			setTime() {
				this.$nextTick(() => {
					let date = new Date(this.time)
					this.list[10].value =
						`${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
					this.timeshow = false
				})
			},
			/* 日期 */
			getTimeDate(){
				if(this.list[14].value == ''){
					this.$refs.datepicker.innerValue = Number(new Date())
				}else{
					this.$refs.datepicker.innerValue = Number(new Date(this.list[14].value))
				}
				this.dateshow = true
			},
			setTimeDate(){
				this.$nextTick(() => {
					let date = new Date(this.dateT)
					this.list[14].value =
						`${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
					this.dateshow = false
				})
			},
			/* 照片 */
			getFile() {
				let that = this
				window.croods.customPlugin({
					action: 'ServicePermissionPlugin.uploadMaterial',
					params: {
						reason: "获取相机、文件权限",
						imgCount: "1",
						uploadTitle: "请选择上传方式",
						uploadType: "4",
					},
					success: function(res) {
						let tfile = res.files[0]
						if (res.flag) {
							let temp = tfile.file.replace(/[\r\n]/g, "")
							let url = 'data:' + tfile.type + ';base64,' + temp
							tfile.url = url
							that.fileTempList.push(tfile)
						} else {
							that.$u.toast('格式错误，上传失败');
						}
					},
					fail: function(msg) {
						if (msg != null || msg != undefined) {
							that.$u.toast(msg);
						} else {
							that.$u.toast('照片上传失败');
						}
					}
				});
			},
			removeItem(index) {
				this.fileTempList.splice(index, 1);
			},
			async getIds() {
				let that = this
				let fj = '';
				/* 皖事通令牌 */
				if (that.wstoken == '') {
					that.$u.toast('获取用户信息失败，请刷新界面或重新登录')
					return
				}
				let promises = that.fileTempList.map(async item => {
					let temp = {
						wstoken: that.wstoken,
						bizType: "public",
						file: item.file,
						fileName: item.name,
						fileType: item.type
					}
					let res = await uploadFileOfQuestion(temp);
					if (res != undefined || res != null) {
						fj += res.id + ';'
					}
				})
				await Promise.all(promises);
				return fj;
			},
			async getWsToken() {
				let that = this
				window.croods.customPlugin({
					action: "UserPlugin.login",
					params: {},
					success: function(res) {
						that.wstoken = res.token
						that.getAllProjects()
						that.getAllDep()
					},
					fail: function(msg) {
						console.log(msg);
					}
				});
			},
			async submit() {
        if(this.loading) {
          return
        }
				let that = this
				/* 请求参数赋值 */
				that.list.forEach(item => {
					if (that.query.hasOwnProperty(item.code)) {
						that.query[item.code] = item.value;
					}
				})
				that.query.xmid = that.list[1].id
				that.query.jsdwid = that.list[2].id
				that.query.trbmId = that.list[6].id
				/* 参数检验 */
				let ignoreFields = ['jsdwid', 'trbmId', 'xmid', 'xcfj']
				for (let key in that.query) {
					if (!ignoreFields.includes(key) && (that.query[key] === '' || that.query[key] === 0)) {
						let temp = that.list.find(item => item.code == key)
						let name = temp.name + '为空，请查看'
						that.$u.toast(name)
						return
					}
				}

				/* let bh = that.query.yjbh
				let reg = /^[a-zA-Z0-9]+$/
				if (!reg.test(bh)) {
				   that.$u.toast('意见单编号不允许输入中文或特殊字符')
				   return
				} */

				if (that.query.xmid == 0) {
					that.$u.toast('未获取到项目ID，请重新选择项目名称')
					return
				}
				if (that.query.jsdwid == 0) {
					that.$u.toast('未获取到建设单位ID，请重新选择建设单位')
					return
				}
				if (that.query.trbmId == 0) {
					that.$u.toast('未获取到责任部门ID，请重新选择责任部门')
					return
				}
				/* if(that.fileTempList.length==0){
					that.$u.toast('现场照片未上传')
					return
				} */
				let fj = await that.getIds()
				that.fileNum = fj.slice(0, -1)
				that.query.xcfj = that.fileNum
				
				/* if(that.query.xcfj==''){
					that.$u.toast('现场照片上传失败，请重新上传')
					return
				} */
				/* that.query.xcfj = '12071' */
        this.loading = true
				addPro(that.query).then(res => {
					if ("msgCode" in res && res.msgCode == "200") {
						that.$u.toast('提交成功');
						setTimeout(function() {
							uni.navigateBack({
								delta: 1
							});
						}, 1000);
					} else {
						that.$u.toast('提交失败')
					}
				}).finally(() => {
          this.loading = false
        })
			},
			reset() {
        if(this.loading) {
          return
        }
				this.list.forEach(item => {
					item.value = ''
				})
				this.list[8].value = '芜湖市排水管理服务中心'
				this.list[1].id = 0
				this.list[2].id = 0
				this.list[6].id = 0
				this.fileTempList = []
				this.fileNum = null
			}
		},
		mounted() {
			this.getWsToken()
		}
	}
</script>

<style scoped>
	.list>.top {
		font-size: 14px;
		color: #999;
		font-family: 'PingFang SC';
		margin-bottom: 8px;
	}

	.photo>.top {
		font-size: 14px;
		color: #999;
		font-family: 'PingFang SC';
		margin-bottom: 8px;
	}

	.a>>>.u-textarea__field {
		font-size: 16px !important;
		color: #303133 !important;
	}

	.d>>>.u-textarea__field {
		font-size: 16px !important;
		color: #303133 !important;
	}
</style>